/*
 * @Author: zusw
 * @Date: 2020-01-14 11:03:08
 * @Description: 角色列表接口集合
 * @LastEditors  : zusw
 * @LastEditTime : 2020-01-20 15:34:21
 */
import { stringify } from 'qs';
import request from '../utils/request';

// 获取列表
export async function page(params) {
  return request(`/role/findbypage?${stringify(params)}`, {
    method: 'GET',
  });
}
// 角色详情
export async function fetchDetail(params) {
  return request(`/role/finddetail/${params.sid}`, {
    method: 'GET',
  });
}
// 新增
export async function add(params) {
  return request('/role/add', {
    method: 'POST',
    data: {
      ...params,
      method: 'post',
    },
  });
}
// 角色编辑
export async function edit(params) {
  return request('/role/edit', {
    method: 'POST',
    data: {
      ...params,
      method: 'post',
    },
  });
}
// 获取详情组织树
export async function getResourceData() {
  return request.get(`/resource/findresourcetree`);
}
// 角色删除
export async function remove(params) {
  return request(`/role/delete/${params}`, {
    method: 'POST',
  });
}
export async function batchesRemove(params) {
  return request(`/role/batchesRemove/${params}`, {
    method: 'DELETE',
  });
}
export async function getResources(params) {
  return request(`/role/resourceIds/${params}`, {
    method: 'GET',
  });
}
export async function getTree(params) {
  return request(`/role/resourceTree/${params}`, {
    method: 'GET',
  });
}
export async function getAllResource() {
  return request('/resource', {
    method: 'GET',
  });
}
export async function getUserResource() {
  return request('/resource/user', {
    method: 'GET',
  });
}
export async function bindResource(params) {
  return request('/role/bindResource', {
    method: 'POST',
    body: {
      ...params,
      method: 'post',
    },
  });
}
